dojo.declare("MCustomerOrderHistoryPg", wm.Page, {
start: function() {
this.loadHistory();
},
"preferredDevice": "phone",
list1OrderIdFormat: function(inValue, rowId, cellId, cellField, cellObj, rowObj) {
var comment = "";
var vendorComment = "";
if (rowObj.comments && rowObj.comments !== null) {
comment = rowObj.comments;
}
if (rowObj.vendor_comment && rowObj.vendor_comment !== null) {
vendorComment = rowObj.vendor_comment;
}
var display = " <div style='font-weight: normal;'>Order#:" + rowObj.orderId + ", " + // "</div>" +
// "<div class='MobileRow'>" +
wm.List.prototype.dateFormatter({
"formatLength": "medium",
"dateType": "date and time"
}, null, null, null, rowObj.orderDt) + "</div>" + "<div style='display:block;font-weight: normal;'>Vendor: " + rowObj.customerByVendorId.name + ", Order Status: " + rowObj.status //"</div>"+
// "<div style='display:block;font-weight: normal;'>Order Status :" + rowObj.status +
// "</div>"
+ "<div style='display:block;font-weight: normal;'>My Comments:" + comment + "</div>"
+ "<div style='display:block;font-weight: normal;'>Vendor Comments:" + vendorComment + "</div>"
display = display + "  <div style='display:block;font-weight: normal;'>Price    :Rs " + rowObj.totalPrice + "  </div> "
return display;
},
list1Select2: function(inSender, inItem) {
// this.mbCustomerHistory.setShowing(true);
//  this.labelOrderItemDetails.setShowing(true);
//  this.labelOrderDetails.setShowing(false);
wm.Page.getPage("MCustomerHomePg").vPageBack = "CUSTOMER_HISTORY";
},
list2OrderItemIdFormat: function(inValue, rowId, cellId, cellField, cellObj, rowObj) {
var display = "<div style='display:block;font-weight: normal;'> <b>" + rowObj.quantity + " " + rowObj.items.itemName + "  Price: Rs " + rowObj.price + "</b></div>";
//"<div class='MobileRow'>Item Desc: " + rowObj.items.itemDesc +
//  "</div>" + "<div style='display:block;font-weight: normal;'>Quantity:<b> " + rowObj.quantity + "</b> Price: Rs <b>" + rowObj.price + "</b></div>";
// "</div>" + "<div class='MobileRow'>Price: " + rowObj.price + "</div>"
if (rowObj.comments && rowObj.comments != null) {
// display = display + " <div class='MobileRow'>Comments: " + rowObj.comments + "</div>"
};
var unit = rowObj.items.unit;
if (!unit || unit === null) {
unit = "";
}
display = " <div style='display:block;font-weight: normal;'> <b> &nbsp;&nbsp;";
display = display + rowObj.items.itemName + "," + rowObj.price + "Rs (" + rowObj.quantity + " " + unit + " @" + rowObj.items.price + "Rs)";
display = display + "</br> ";
display = display + "</b></div> ";
return display;
},
labelBackToResultsClick: function(inSender, inEvent) {
this.labelBackToResults.setShowing(false);
this.labelOrderItemDetails.setShowing(false);
this.labelOrderDetails.setShowing(true);
this.layerOrders.activate();
},
loadHistory: function() {
var mainPage = wm.Page.getPage("MobileMainPg");
this.lvMyOrders.filter.setValue("customerByCustomerId.customerId", mainPage.vUserId);
this.lvMyOrders.update();
},
list1StatusFormat: function(inValue, rowId, cellId, cellField, cellObj, rowObj) {
var buttonText = '<img src ="resources/images/mobile/next_img.png" height="26px" />';
return buttonText;
},
svClearHistoryError: function(inSender, inError) {
},
lvOrderItemsSuccess: function(inSender, inDeprecated) {
var display = ""; //" <div style='display:block;font-weight: normal;'> <b>";
for (var count = 0; count < this.lvOrderItems.getCount(); count++) {
var vItem = this.lvOrderItems.getItem(count);
var unit = vItem.data.items.data.unit;
if (!unit || unit === null) {
unit = "";
}
display = display + " <div style='display:block;font-weight: normal;'> <b> &nbsp;&nbsp;";
display = display + vItem.data.items.data.itemName + "," + vItem.data.price + "Rs (" + vItem.data.quantity + " " + unit + " @" + vItem.data.items.data.price + "Rs)";
display = display + "</br> ";
display = display + "</b></div> ";
}
this.labelOrderDetailsList.setCaption(display);
},
_end: 0
});

MCustomerOrderHistoryPg.widgets = {
lvMyOrders: ["wm.LiveVariable", {"autoUpdate":false,"designMaxResults":10,"inFlightBehavior":"executeLast","maxResults":10,"orderBy":"desc: orderDt","startUpdate":false,"type":"com.servicelivedb.data.Order"}, {}, {
liveView: ["wm.LiveView", {"dataType":"com.servicelivedb.data.Order","related":["customerByVendorId"],"view":[
{"caption":"OrderId","sortable":true,"dataIndex":"orderId","type":"java.lang.Integer","displayType":"Number","required":true,"readonly":true,"includeLists":true,"includeForms":true,"order":1000,"subType":null,"widthUnits":"px"},
{"caption":"Status","sortable":true,"dataIndex":"status","type":"java.lang.String","displayType":"Text","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1001,"subType":null,"widthUnits":"px"},
{"caption":"Address","sortable":true,"dataIndex":"address","type":"java.lang.String","displayType":"Text","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1002,"subType":null,"widthUnits":"px"},
{"caption":"UpdatedBy","sortable":true,"dataIndex":"updatedBy","type":"java.lang.String","displayType":"Text","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1003,"subType":null,"widthUnits":"px"},
{"caption":"Comments","sortable":true,"dataIndex":"comments","type":"java.lang.String","displayType":"Text","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1004,"subType":null,"widthUnits":"px"},
{"caption":"TotalPrice","sortable":true,"dataIndex":"totalPrice","type":"java.math.BigDecimal","displayType":"Number","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1005,"subType":null,"widthUnits":"px"},
{"caption":"ContactNum","sortable":true,"dataIndex":"contactNum","type":"java.lang.String","displayType":"Text","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1006,"subType":null,"widthUnits":"px"},
{"caption":"CouponCode","sortable":true,"dataIndex":"couponCode","type":"java.lang.String","displayType":"Text","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1007,"subType":null,"widthUnits":"px"},
{"caption":"Discount","sortable":true,"dataIndex":"discount","type":"java.lang.String","displayType":"Text","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1008,"subType":null,"widthUnits":"px"},
{"caption":"OrderDt","sortable":true,"dataIndex":"orderDt","type":"java.util.Date","displayType":"Date","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1009,"subType":null,"widthUnits":"px"},
{"caption":"Active","sortable":true,"dataIndex":"active","type":"java.lang.Boolean","displayType":"CheckBox","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1010,"subType":null,"widthUnits":"px"},
{"caption":"Vendor_comment","sortable":true,"dataIndex":"vendor_comment","type":"java.lang.String","displayType":"Text","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":1011,"subType":null,"widthUnits":"px"}
]}, {}],
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"[mobileMainPg].vUserId.dataValue","targetProperty":"filter.customerByCustomerId.customerId"}, {}],
wire1: ["wm.Wire", {"expression":"true","targetProperty":"filter.active"}, {}]
}]
}],
lvOrderItems: ["wm.LiveVariable", {"autoUpdate":false,"inFlightBehavior":"executeLast","maxResults":20,"orderBy":"asc:items.itemName","startUpdate":false,"type":"com.servicelivedb.data.OrderItems"}, {}, {
liveView: ["wm.LiveView", {"dataType":"com.servicelivedb.data.OrderItems","related":["items"],"view":[
{"caption":"OrderItemId","sortable":true,"dataIndex":"orderItemId","type":"java.lang.Integer","displayType":"Number","required":true,"readonly":true,"includeLists":true,"includeForms":true,"order":7000,"subType":null,"widthUnits":"px"},
{"caption":"Quantity","sortable":true,"dataIndex":"quantity","type":"java.math.BigDecimal","displayType":"Number","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":7001,"subType":null,"widthUnits":"px"},
{"caption":"Price","sortable":true,"dataIndex":"price","type":"java.math.BigDecimal","displayType":"Number","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":7002,"subType":null,"widthUnits":"px"},
{"caption":"Comments","sortable":true,"dataIndex":"comments","type":"java.lang.String","displayType":"Text","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":7003,"subType":null,"widthUnits":"px"},
{"caption":"Status","sortable":true,"dataIndex":"status","type":"java.lang.String","displayType":"Text","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":7004,"subType":null,"widthUnits":"px"},
{"caption":"DlvrQuantity","sortable":true,"dataIndex":"dlvrQuantity","type":"java.math.BigDecimal","displayType":"Number","required":false,"readonly":false,"includeLists":true,"includeForms":true,"order":7005,"subType":null,"widthUnits":"px"},
{"caption":"ItemId","sortable":true,"dataIndex":"items.itemId","type":"java.lang.Integer","displayType":"Number","required":true,"widthUnits":"px","includeLists":true,"includeForms":true,"order":8000},
{"caption":"ItemName","sortable":true,"dataIndex":"items.itemName","type":"java.lang.String","displayType":"Text","required":false,"widthUnits":"px","includeLists":true,"includeForms":true,"order":8001},
{"caption":"ItemDesc","sortable":true,"dataIndex":"items.itemDesc","type":"java.lang.String","displayType":"Text","required":false,"widthUnits":"px","includeLists":true,"includeForms":true,"order":8002},
{"caption":"Price","sortable":true,"dataIndex":"items.price","type":"java.math.BigDecimal","displayType":"Number","required":false,"widthUnits":"px","includeLists":true,"includeForms":true,"order":8005},
{"caption":"Unit","sortable":true,"dataIndex":"items.unit","type":"java.lang.String","displayType":"Text","required":false,"widthUnits":"px","includeLists":true,"includeForms":true,"order":8007}
]}, {}],
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"list1.selectedItem","targetProperty":"filter.order"}, {}]
}]
}],
svClearHistory: ["wm.ServiceVariable", {"inFlightBehavior":"executeLast","operation":"clearCustomerOrderHistoryDetails","service":"serviceliveDB"}, {"onError":"svClearHistoryError","onSuccess":"lvMyOrders"}, {
input: ["wm.ServiceInput", {"type":"clearCustomerOrderHistoryDetailsInputs"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":"false","targetProperty":"status"}, {}],
wire1: ["wm.Wire", {"expression":"${[mobileMainPg].vUserId}","targetProperty":"customerId"}, {}]
}]
}]
}],
ncConfirmDelete: ["wm.NotificationCall", {"operation":"confirm"}, {"onOk":"svClearHistory"}, {
input: ["wm.ServiceInput", {"type":"confirmInputs"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":"\"Do you want to delete the Order History?\"","targetProperty":"text"}, {}],
wire1: ["wm.Wire", {"expression":"\"Yes\"","targetProperty":"OKButtonText"}, {}],
wire2: ["wm.Wire", {"expression":"\"No\"","targetProperty":"CancelButtonText"}, {}]
}]
}]
}],
ldOrders: ["wm.LoadingDialog", {"caption":"Loading Orders.."}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"panel4","targetProperty":"widgetToCover"}, {}],
wire1: ["wm.Wire", {"expression":undefined,"source":"lvMyOrders","targetProperty":"serviceVariableToTrack"}, {}]
}]
}],
ldOrdersItems: ["wm.LoadingDialog", {"caption":"Loading Order Details..","captionWidth":"200px","serviceVariableToTrack":["lvOrderItems","svClearHistory"]}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"layoutBox1","targetProperty":"widgetToCover"}, {}]
}]
}],
layoutBox1: ["wm.Layout", {"horizontalAlign":"left","styles":{},"verticalAlign":"top"}, {}, {
panel8: ["wm.Panel", {"desktopHeight":"35px","enableTouchHeight":true,"height":"35px","horizontalAlign":"left","layoutKind":"left-to-right","mobileHeight":"35px","showing":false,"styles":{},"verticalAlign":"top","width":"100%"}, {}, {
labelBackToResults: ["wm.Label", {"caption":"Back","height":"100%","padding":"4","showing":false,"styles":{"color":"#1235a8"},"width":"59px"}, {"onclick":"labelBackToResultsClick"}],
labelOrderDetails: ["wm.Label", {"align":"left","caption":"Orders (Select to view Items)","height":"100%","padding":"4","showing":false,"styles":{"fontWeight":"bold","backgroundColor":"#b79c9c"},"width":"100%"}, {}],
labelOrderItemDetails: ["wm.Label", {"align":"center","caption":"Orders Item Details","height":"100%","padding":"2","showing":false,"styles":{"fontWeight":"bold","backgroundColor":"#b79c9c"},"width":"100%"}, {}]
}],
layersContent: ["wm.Layers", {"defaultLayer":0,"width":"98%"}, {}, {
layerOrders: ["wm.Layer", {"borderColor":"","caption":"layer1","horizontalAlign":"center","themeStyleType":"","verticalAlign":"top"}, {}, {
panel4: ["wm.Panel", {"autoScroll":true,"height":"100%","horizontalAlign":"center","styles":{},"verticalAlign":"top","width":"100%"}, {}, {
button1: ["wm.Button", {"border":"1","caption":"Delete Order History","height":"40px","imageIndex":21,"imageList":"app.silkIconList","styles":{},"width":"95%"}, {"onclick":"ncConfirmDelete"}],
list1: ["wm.List", {"_classes":{"domNode":["MobileListStyle"]},"columns":[
{"show":false,"field":"orderId","title":"Order#","width":"100%","align":"left","formatFunc":"list1OrderIdFormat","editorProps":{"restrictValues":true},"mobileColumn":true},
{"show":false,"field":"status","title":"Status","width":"30px","align":"right","formatFunc":"list1StatusFormat","mobileColumn":true},
{"show":false,"field":"address","title":"Address","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"contactNum","title":"ContactNum","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"updatedBy","title":"UpdatedBy","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"comments","title":"Comments","width":"100%","align":"left","formatFunc":"","editorProps":{"restrictValues":true},"mobileColumn":false},
{"show":false,"field":"totalPrice","title":"TotalPrice","width":"80px","align":"center","formatFunc":"","editorProps":{"restrictValues":true},"expression":"\"<div class='MobileRow'>TotalPrice: \" +${totalPrice}+ \"</div>\"","mobileColumn":false},
{"show":false,"field":"PHONE COLUMN","title":"-","width":"100%","align":"left","editorProps":{"restrictValues":true},"expression":"","mobileColumn":false},
{"show":false,"field":"couponCode","title":"CouponCode","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"discount","title":"Discount","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"orderDt","title":"OrderDt","width":"80px","align":"left","formatFunc":"wm_date_formatter","mobileColumn":false},
{"show":false,"field":"active","title":"Active","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"vendor_comment","title":"Vendor_comment","width":"100%","align":"left","formatFunc":"","mobileColumn":false}
],"headerVisible":false,"height":"100%","isNavigationMenu":true,"margin":"1","minHeight":0,"minWidth":0,"padding":"0,0,0,0","styleAsGrid":false,"styles":{}}, {"onSelect":"lvOrderItems","onSelect1":"layerOrderItems","onSelect2":"list1Select2"}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"lvMyOrders","targetProperty":"dataSet"}, {}]
}]
}]
}]
}],
layerOrderItems: ["wm.Layer", {"autoScroll":true,"borderColor":"","caption":"layer1","horizontalAlign":"left","styles":{},"themeStyleType":"","verticalAlign":"top"}, {}, {
list2: ["wm.List", {"_classes":{"domNode":["MobileListStyle"]},"borderColor":"#e81a1a","columns":[
{"show":false,"field":"orderItemId","title":"OrderItemId","width":"100%","align":"left","formatFunc":"list2OrderItemIdFormat","editorProps":{"restrictValues":true},"expression":"\n\n","mobileColumn":true},
{"show":false,"field":"quantity","title":"Quantity","width":"45px","align":"left","formatFunc":"list3QuantityFormat","mobileColumn":false},
{"show":false,"field":"price","title":"Add to Cart","width":"50px","align":"left","formatFunc":"list3PriceFormat","expression":"","mobileColumn":false},
{"show":false,"field":"comments","title":"Comments","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"PHONE COLUMN","title":"-","width":"100%","align":"left","expression":"","mobileColumn":false},
{"show":false,"field":"status","title":"Status","width":"40px","align":"right","formatFunc":"wm_button_formatter","editorProps":{"restrictValues":true},"mobileColumn":false},
{"show":false,"field":"dlvrQuantity","title":"DlvrQuantity","width":"80px","align":"left","formatFunc":"","editorProps":{"restrictValues":true},"mobileColumn":false},
{"show":false,"field":"items.itemName","title":"Items.itemName","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"items.itemDesc","title":"Items.itemDesc","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"items.itemId","title":"Items.itemId","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"items.price","title":"Items.price","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"items.unit","title":"Items.unit","width":"100%","align":"left","formatFunc":"","mobileColumn":false}
],"headerVisible":false,"height":"100%","margin":"1","minHeight":0,"minWidth":0,"padding":"0,0,0,0","selectionMode":"none","styleAsGrid":false,"styles":{}}, {"onGridButtonClick":"list3GridButtonClick","onSelect":"list3Select"}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"lvOrderItems","targetProperty":"dataSet"}, {}],
wire1: ["wm.Wire", {"expression":undefined,"source":"list1.emptySelection","targetProperty":"disabled"}, {}]
}]
}]
}]
}]
}]
};

MCustomerOrderHistoryPg.prototype._cssText = '';
MCustomerOrderHistoryPg.prototype._htmlText = '';